package com.hotline.communication.service.impl;

import com.hotline.communication.mapper.RecordLogMapper;
import com.hotline.communication.dto.RecordLogDTO;
import com.hotline.communication.service.RecordLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class RecordLogServiceImpl implements RecordLogService {

    @Resource
    private RecordLogMapper recordLogMapper;

    @Override
    public RecordLogDTO selectById(String id) {
        RecordLogDTO recordLogDTO = recordLogMapper.selectById(id);
        return recordLogDTO;
    }

    @Override
    public void insert(RecordLogDTO recordLogDTO) {
        try {
            log.info("TX_LOG[]record_log[]录音记录[]新增录音记录[]recordLogDTO:{}",recordLogDTO);
            recordLogMapper.insert(recordLogDTO);
        }catch (Exception e){
            log.error("新增录音记录失败, recordLogDTO={}, cause:{}", recordLogDTO,e.getMessage());
        }
    }

    @Override
    public void update(RecordLogDTO recordLogDTO) {
        try {
            log.info("TX_LOG[]record_log[]录音记录[]更新录音记录[]recordLogDTO:{}",recordLogDTO);
            recordLogMapper.update(recordLogDTO);
        }catch (Exception e){
            log.error("更新录音记录失败, recordLogDTO={}, cause:{}", recordLogDTO,e.getMessage());
        }
    }

    @Override
    public void delete(String id) {
        try {
            log.info("TX_LOG[]record_log[]录音记录[]删除录音记录[]id:{}",id);
            recordLogMapper.delete(id);
        }catch (Exception e){
            log.error("删除录音记录失败, id={}, cause:{}", id,e.getMessage());
        }
    }
}
